<?php
/**
 * PddAuthCatsDao.php class file.
 * @author wudg <544038230@qq.com>
 * @date 2021/1/17- 下午4:19
 */

namespace common\jobs\dao;


use common\exception\ValidatorException;
use common\library\BaseDao;
use common\models\pdd\PddAuthCats;

class PddAuthCatsDao extends BaseDao
{
    /**
     * 写入信息
     * @param array $data
     * @return PddAuthCats
     * @throws ValidatorException
     */
    public function insertData(array $data)
    {
        $authCats = new PddAuthCats();

        $authCats->load($data,'');

        if (!$authCats->validate()) {
            throw new ValidatorException($authCats->errorsToString());
        }

        if($authCats->save())
        {
            return $authCats;
        }else{
            throw new ValidatorException($authCats->errorsToOneString());
        }
    }
}